//
//  DetailBackButton.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/9/13.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class DetailBackButton: UIView {
    var backButton:UIButton!
    var avatarImage:UIImageView!
    var userName:UILabel!
    
    override init(frame: CGRect) {
        backButton = UIButton()
        avatarImage = UIImageView()
        userName = UILabel()
        super.init(frame: frame)
        self.createbackIcon()
        self.addAvatarImage()
        self.addUserName()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //添加返回图标
    func createbackIcon(){
        backButton.frame = CGRect(x: 0, y: 8, width: 20.2, height: 20)
        backButton.setImage(UIImage(named: "backLight"), forState: UIControlState())
        self.addSubview(backButton)
    }
    
    //添加头像
    func addAvatarImage(){
        avatarImage.frame = CGRect(x: 25, y: 3, width: 30, height: 30)
        avatarImage.image = UIImage(named: "noAvatar")
        self.addSubview(avatarImage)
        
        //在头像上面添加一层中间有圆形透明的view  使头像变成圆形的
        let cornerRadiusView = UIImageView(frame: CGRectMake(-1, -1, 32*SCALEW, 32*SCALEW))
        cornerRadiusView.image = UIImage(named: "makeImagecornerRadiusB")
        avatarImage.addSubview(cornerRadiusView)
    }
    
    //添加用户名
    func addUserName(){
        userName.frame = CGRect(x: 68, y: 10, width: 160*SCALEW, height: 16)
        userName.textAlignment = .Left
        userName.textColor = UIColor.whiteColor()
        userName.font = BaseFunc.getCustomFont(14)
        userName.text = ""
        self.addSubview(userName)
    }

}










